﻿<%@ Page Title="" Language="C#" MasterPageFile="ReconSite.Master" AutoEventWireup="true"
    CodeBehind="RemitterMaster.aspx.cs" Inherits="Recon.Portal.WebUI.RemitterMaster" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<asp:Content ID="TitleContent" ContentPlaceHolderID="TitleHolder" runat="server">
    <title>Remitter Maintenance</title>
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="BodyHolder" runat="server">
    <div class="formDiv" style="width:63%">
    <h2 class="formTitle">Remitter Master</h2>
    <h1 class="formError" style="text-align:right;font-size:smaller;color:#CC2900;">Fields marked with * are mandatory</h1>
	<%--<span id="mandatoryMessage" class="formError">Fields marked with * are mandatory</span>--%>
    <table cellspacing="1" cellpadding="1" border="0" width="100%">
        <%--<tr>
            <td align="right">
                Option<span class="required">*</span>
            </td>
            <td colspan="3">
                    <asp:RadioButtonList ID="rbOption" runat="server" RepeatDirection="Horizontal" 
                        RepeatLayout="Flow" onselectedindexchanged="rbOption_SelectedIndexChanged" 
                        AutoPostBack="True" >
                    <asp:ListItem Value="1" Selected="True">Add</asp:ListItem>
                    <asp:ListItem Value="2">Modify</asp:ListItem>
                    </asp:RadioButtonList>
            </td>
            
        </tr>--%>
        <tr>
            <td align="right">
                Remitter ID<span class="required">*</span>
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtRemitterId" runat="server"  MaxLength="10"></asp:TextBox>
               <%-- <asp:Button ID="bntbrowse" runat="server" Text="..." Width="25px"   OnClick="bntbrowse_Click" CausesValidation="False" />
                <asp:Button ID="bntgetdetails" runat="server" Text="Get Details" OnClick="bntgetdetails_Click" CausesValidation="False" OnClientClick="javascript:return SelectUser();" />--%>
                <asp:RequiredFieldValidator ID="reqRemitterId" runat="server" 
                    ErrorMessage="Enter Remitter Id" CssClass="formError"
                    ControlToValidate="txtRemitterId" InitialValue="" 
                    SetFocusOnError="True"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="regRemitterId" runat="server" 
                    ControlToValidate="txtRemitterId" CssClass="formError"
                    ErrorMessage="Invalid Remitterid" ValidationExpression="^[0-9a-zA-Z]+$" 
                    SetFocusOnError="True"></asp:RegularExpressionValidator>
            </td>
        </tr> 
         <tr>
            <td align="right">
                Discount Code
            </td>
            <td>
                <input id="txtDiscountcode" style="width: 125px" type="text" 
                    runat="server" enableviewstate="false"  readonly="readonly" />
                <asp:Button ID="bntbrowseDiscount" runat="server" Text="..." Width="25px"   OnClick="bntbrowseDiscount_Click" CausesValidation="False" />
            </td>
            <td align="left">
                Penalty Code
            </td>
            <td align="left">
                <input id="txtPenaltycode" style="width: 125px" type="text" 
                    runat="server" enableviewstate="false"  readonly="readonly" />
                <asp:Button ID="bntbrowsePenalty" runat="server" Text="..." Width="25px"   OnClick="bntbrowsePenalty_Click" CausesValidation="False" />
            </td>
        </tr>
        <tr>
            <td align="right">
                Remitter Name<span class="required">*</span>
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtRemitterName" runat="server" MaxLength="100"></asp:TextBox>
                &nbsp;<asp:RequiredFieldValidator ID="reqTxtName" runat="server" 
                    ErrorMessage="Enter Remitter Name" CssClass="formError"
                    ControlToValidate="txtRemitterName" SetFocusOnError="True"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="regRemitterName" runat="server" 
                    ErrorMessage="Invalid Remitter Name" CssClass="formError"
                    ControlToValidate="txtRemitterName" SetFocusOnError="True" 
                    ValidationExpression="^[a-zA-Z' '.&amp;-]+$"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <td align="right">
                Address1<span class="required">*</span>
            </td>
            <td>
                <asp:TextBox ID="txtAddress1" runat="server" MaxLength="50"></asp:TextBox>
                &nbsp;<asp:RequiredFieldValidator ID="reqAddress1" runat="server" 
                    ErrorMessage="Enter Address1" CssClass="formError"
                    ControlToValidate="txtAddress1" SetFocusOnError="True"></asp:RequiredFieldValidator>
            </td>
            <td align="right">
                Address2<span class="required">*</span>
            </td>
            <td >
                <asp:TextBox ID="txtAddress2" runat="server" MaxLength="50"></asp:TextBox>
                &nbsp;<asp:RequiredFieldValidator ID="reqAddress2" runat="server" 
                    ErrorMessage="Enter Address2" CssClass="formError"
                    ControlToValidate="txtAddress2" SetFocusOnError="True"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <%--<tr>
            <td align="right">
                Address2<span class="required">*</span>
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtAddress2" runat="server" MaxLength="50"></asp:TextBox>
                &nbsp;<asp:RequiredFieldValidator ID="reqAddress2" runat="server" 
                    ErrorMessage="Address2 is mandatory" CssClass="formError"
                    ControlToValidate="txtAddress2" SetFocusOnError="True"></asp:RequiredFieldValidator>
            </td>
        </tr>--%>
        <tr>
            <td align="right">
                Address3<%--<span class="required">*</span>--%>
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtAddress3" runat="server" MaxLength="50"></asp:TextBox>
                &nbsp;<%--<asp:RequiredFieldValidator ID="reqAddress3" runat="server" 
                    ErrorMessage="Address3 is mandatory" CssClass="formError"
                    ControlToValidate="txtAddress3" SetFocusOnError="True"></asp:RequiredFieldValidator>--%>
            </td>
        </tr>
       
        
        <tr>
            <td align="right">
                City<span class="required">*</span>
            </td>
            <td>
                <asp:TextBox ID="txtCity" runat="server" MaxLength="35"></asp:TextBox>
                <asp:RequiredFieldValidator ID="reqtxtCity" runat="server" 
                    ErrorMessage="Enter City" CssClass="formError"
                    ControlToValidate="txtCity" SetFocusOnError="True"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="regCity" runat="server" 
                    ControlToValidate="txtCity" CssClass="formError" 
                    ErrorMessage="Invalid city" SetFocusOnError="True" 
                    ValidationExpression="^[a-zA-Z' '.]+$"></asp:RegularExpressionValidator>
            </td>
            <td align="right">
                State<span class="required">*</span>
            </td>
            <td>
                <asp:TextBox ID="txtState" runat="server" MaxLength="35"></asp:TextBox>
                <asp:RequiredFieldValidator ID="reqState" runat="server" 
                    ErrorMessage="Enter State" CssClass="formError"
                    ControlToValidate="txtState" SetFocusOnError="True"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="regState" runat="server" 
                    ControlToValidate="txtState" CssClass="formError" 
                    ErrorMessage="Invalid State" SetFocusOnError="True" 
                    ValidationExpression="^[a-zA-Z' ']+$"></asp:RegularExpressionValidator>
            </td>
        </tr>
      <%--  <tr>
            <td align="right">
                State<span class="required">*</span>
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtState" runat="server" MaxLength="35"></asp:TextBox>
                <asp:RequiredFieldValidator ID="reqState" runat="server" 
                    ErrorMessage="State is mandatory" CssClass="formError"
                    ControlToValidate="txtState" SetFocusOnError="True"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="regState" runat="server" 
                    ControlToValidate="txtState" CssClass="formError" 
                    ErrorMessage="Invalid State" SetFocusOnError="True" 
                    ValidationExpression="^[a-zA-Z' ']+$"></asp:RegularExpressionValidator>
            </td>
        </tr>--%>
        <tr>
            <td align="right">
                Zip Code
            </td>
            <td >
                <asp:TextBox ID="txtZipCode" runat="server" MaxLength="10"></asp:TextBox>
                <asp:RegularExpressionValidator ID="regZipCode" runat="server" 
                    ErrorMessage="Invalid zip code" CssClass="formError"
                    ControlToValidate="txtZipCode" SetFocusOnError="True" 
                    ValidationExpression="^[1-9][0-9]{1,}$"></asp:RegularExpressionValidator>
            </td>
            <td align="right">
                Country<span class="required">*</span>
            </td>
            <td >
                <asp:TextBox ID="txtCountry" runat="server" MaxLength="35"></asp:TextBox>
                <asp:RequiredFieldValidator ID="reqCountry" runat="server" 
                    ErrorMessage="Enter Country" CssClass="formError"
                    ControlToValidate="txtCountry" SetFocusOnError="True"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                    ControlToValidate="txtCountry" CssClass="formError" 
                    ErrorMessage="Invalid country" SetFocusOnError="True" 
                    ValidationExpression="^[a-zA-Z' ']+$"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <%-- <tr>
            <td align="right">
                Country<span class="required">*</span>
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtCountry" runat="server" MaxLength="35"></asp:TextBox>
                <asp:RequiredFieldValidator ID="reqCountry" runat="server" 
                    ErrorMessage="Country is mandatory" CssClass="formError"
                    ControlToValidate="txtCountry" SetFocusOnError="True"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                    ControlToValidate="txtCountry" CssClass="formError" 
                    ErrorMessage="Invalid country" SetFocusOnError="True" 
                    ValidationExpression="^[a-zA-Z' ']+$"></asp:RegularExpressionValidator>
            </td>
        </tr>--%>
        <tr>
            <td align="right">
                Phone
            </td>
            <td >
                <asp:TextBox ID="txtPhone" runat="server" MaxLength="15"></asp:TextBox>
                <asp:RegularExpressionValidator ID="regPhone" runat="server" ErrorMessage="Invalid phone"
                    ControlToValidate="txtPhone" SetFocusOnError="True" 
                    ValidationExpression="^[0-9]{1,}$" CssClass="formError"></asp:RegularExpressionValidator>
            </td>
            <td align="right">
                Email
            </td>
            <td >
                <asp:TextBox ID="txtEmail" runat="server" MaxLength="100"></asp:TextBox>
                <asp:RegularExpressionValidator ID="regTxtEmail" runat="server" 
                    ErrorMessage="Invalid email" CssClass="formError"
                    ControlToValidate="txtEmail" SetFocusOnError="True" 
                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <%--<tr>
            <td align="right">
                Email
            </td>
            <td colspan="3">
                <asp:TextBox ID="txtEmail" runat="server" MaxLength="100"></asp:TextBox>
                <asp:RegularExpressionValidator ID="regTxtEmail" runat="server" 
                    ErrorMessage="Invalid email" CssClass="formError"
                    ControlToValidate="txtEmail" SetFocusOnError="True" 
                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
            </td>
        </tr>--%>
        <tr>
            <td align="right">              
            </td>
            <td colspan="3" >
                <asp:CheckBox ID="chkIsenabled" runat="server" Checked="True" Text="Enable" />
                <%--&nbsp;&nbsp; <asp:CheckBox ID="chkActive" runat="server" Text="Active" 
                    Checked="True" TabIndex="14" />--%>
            </td>
        </tr>
        <tr>
            <td align="right">
                &nbsp;
            </td>
            <td colspan="3" >
                <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />&nbsp;
                <asp:Button ID="btnCancel" runat="server" Text="Reset" CausesValidation="False" OnClick="btnCancel_Click" />
            </td>
        </tr>
    </table>

         <div style="height:140px; width:100%; overflow:auto;">
                <asp:GridView ID="gvCustomer" runat="server" AllowPaging="false" 
                        AutoGenerateColumns="False" Width="100%"
                        HeaderStyle-BackColor="silver" HeaderStyle-ForeColor="#6f788f" 
                            HeaderStyle-Font-Bold="false" OnRowDeleting="gvCustAccount_RowDeleting">
                    <EmptyDataTemplate>
                        <asp:Label ID="lblNoRows" runat="server" Text="No records found for customer account detail." />
                    </EmptyDataTemplate>
                    <Columns>
                        <asp:TemplateField HeaderText="" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:LinkButton  ID = "lnkSelect" runat="server"  Text = "Select"  CausesValidation="false" CommandName="Select"></asp:LinkButton>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Remitter ID" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblRemitterID" runat="server" Text='<%# Eval("RemitterID") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Discount" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblDiscount" runat="server" Text='<%# Eval("DiscountCode") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Penalty" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblPenalty" runat="server" Text='<%# Eval("PenaltyCode") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Name" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblName" runat="server" Text='<%# Eval("RemitterName") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Address1" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblAddress1" runat="server" Text='<%# Eval("Address1") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Address2" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblAddress2" runat="server" Text='<%# Eval("Address2") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Address3" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblAddress3" runat="server" Text='<%# Eval("Address3") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                         <asp:TemplateField HeaderText="City" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblCity" runat="server" Text='<%# Eval("City") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                         <asp:TemplateField HeaderText="State" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblState" runat="server" Text='<%# Eval("State") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Country" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblCountry" runat="server" Text='<%# Eval("Country") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        
                         <asp:TemplateField HeaderText="Zip Code" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblZipCode" runat="server" Text='<%# Eval("ZipCode") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Phone" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblTelephoneNumber" runat="server" Text='<%# Eval("TelephoneNumber") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Email" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblEmailAddress" runat="server" Text='<%# Eval("EmailAddress") %>' ></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <asp:TemplateField HeaderText="Enabled?" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Label  ID = "lblIsEnabled" runat="server"  Text='<%# Eval("IsEnabled") %>'></asp:Label>
                            </ItemTemplate>
                          </asp:TemplateField>
                        <%--<asp:CommandField HeaderText="Edit" ShowEditButton="True" CausesValidation="false" ItemStyle-HorizontalAlign="Center" />
                        <asp:BoundField HeaderText="Customer Id" DataField="CustomerID" HeaderStyle-Font-Bold = "false" ItemStyle-HorizontalAlign="Center" ReadOnly="True"/>
                        <asp:BoundField HeaderText="Name" DataField="CustomerName" HeaderStyle-Font-Bold = "false" ItemStyle-HorizontalAlign="Center" />
                        <asp:BoundField HeaderText="Address1" DataField="Address1" HeaderStyle-Font-Bold = "false" ItemStyle-HorizontalAlign="Center"/>
                        <asp:BoundField HeaderText="Address2" DataField="Address2" HeaderStyle-Font-Bold = "false" ItemStyle-HorizontalAlign="Center" />
                        <asp:BoundField HeaderText="City" DataField="City" HeaderStyle-Font-Bold = "false" ItemStyle-HorizontalAlign="Center" />
                        <asp:BoundField HeaderText="State" DataField="State" HeaderStyle-Font-Bold = "false" ItemStyle-HorizontalAlign="Center" />
                        <asp:BoundField HeaderText="Zip Code" DataField="ZipCode" HeaderStyle-Font-Bold = "false" ItemStyle-HorizontalAlign="Center" />
                        <asp:BoundField HeaderText="Phone" DataField="TelephoneNumber" HeaderStyle-Font-Bold = "false" ItemStyle-HorizontalAlign="Center" />
                        <asp:BoundField HeaderText="Email" DataField="EmailAddress" HeaderStyle-Font-Bold = "false" ItemStyle-HorizontalAlign="Center" />
                        <asp:CheckBoxField HeaderText="Enabled?" DataField="IsEnabled" HeaderStyle-Font-Bold = "false" ItemStyle-HorizontalAlign="Center" />--%>
                        <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" ItemStyle-HorizontalAlign="Center"/>
                    </Columns>
                </asp:GridView>
                </div>

    <asp:UpdatePanel ID="upUnmatchedLists" runat="server" UpdateMode="Conditional">
        <ContentTemplate>    
                <div id="pnlMatchList" runat="server" class="pnlMatchList">    
                    <span style="azimuth: center;">
                        <div id="Div1" class="formDiv" runat ="server"  >
                            <center>
                                <asp:Label ID="lblMessage" runat="server"    CssClass="lable"/>
                            </center>
                        </div>
                    </span>
                    <div class="formDiv" style="width: 30%;">
                         <center>
                            <asp:Button ID="btnok" runat="server" Text="OK" onclick="btnok_Click" CausesValidation="False"  />
                          </center>
                    </div>
                </div>
            <div style="display: none">
                <asp:Button ID="btnManualPopup" runat="server" />
            </div>
            <ajax:ModalPopupExtender ID="btnClickPopup" runat="server" PopupControlID="pnlMatchList"
                TargetControlID="btnManualPopup" BackgroundCssClass="modalBackground" RepositionMode="RepositionOnWindowScroll" OkControlID = "btnok">
            </ajax:ModalPopupExtender>   
        </ContentTemplate>        
    </asp:UpdatePanel>
    </div>

    <script type="text/javascript">
        $(function () {
            
            $("[id*=lnkSelect]").click(function () {
                var tr = $(this).closest('tr');
                //alert($(this).closest('tr').find('span[id*="lnkSelect"]').attr('Text'));
                var custId = $(tr).find('span[id*="lblRemitterID"]').text();
                var discount = $(tr).find('span[id*="lblDiscount"]').text();
                var penalty = $(tr).find('span[id*="lblPenalty"]').text();
                var custName = $(tr).find('span[id*="lblName"]').text();
                var address1 = $(tr).find('span[id*="lblAddress1"]').text();
                var address2 = $(tr).find('span[id*="lblAddress2"]').text();
                var address3 = $(tr).find('span[id*="lblAddress3"]').text();
                var city = $(tr).find('span[id*="lblCity"]').text();
                var state = $(tr).find('span[id*="lblState"]').text();
                var country = $(tr).find('span[id*="lblCountry"]').text();
                var zipcode = $(tr).find('span[id*="lblZipCode"]').text();
                var phone = $(tr).find('span[id*="lblTelephoneNumber"]').text();
                var email = $(tr).find('span[id*="lblEmailAddress"]').text();
                var isEnable = $(tr).find('span[id*="lblIsEnabled"]').text();

               // alert(isEnable.toString());

                $("#<%= txtRemitterId.ClientID %>").val(custId).text();
                $("#<%= txtDiscountcode.ClientID %>").val(discount).text();
                $("#<%= txtPenaltycode.ClientID %>").val(penalty).text();
                        $("#<%= txtRemitterName.ClientID %>").val(custName).text();
                        $("#<%= txtAddress1.ClientID %>").val(address1).text();
                $("#<%= txtAddress2.ClientID %>").val(address2).text();
                $("#<%= txtAddress3.ClientID %>").val(address3).text();
                        $("#<%= txtCity.ClientID %>").val(city).text();
                $("#<%= txtState.ClientID %>").val(state).text();
                $("#<%= txtCountry.ClientID %>").val(country).text();
                        $("#<%= txtZipCode.ClientID %>").val(zipcode).text();
                        $("#<%= txtPhone.ClientID %>").val(phone).text();
                        $("#<%= txtEmail.ClientID %>").val(email).text();


                var btntext = "Modify";
                $("#<%= btnSubmit.ClientID %>").val(btntext).text();

                        if (isEnable.toString() == "True") {
                            $("#<%= chkIsenabled.ClientID %>").prop('checked', true);
                       }
                       else { $("#<%= chkIsenabled.ClientID %>").prop('checked', false); }

                        return false;
                    });
         });

        function SelectUser() {
            var Username = document.getElementById('<%=txtRemitterId.ClientID %>').value;
            if (Username == '') {
                alert("Remitter Id is Mandatory");
                return false;
            }

            return true;
        }
    </script>
</asp:Content>
